const { categories } = require('../lib/commonData');

const parent = { "enName": "App", "id": 801, "name": "电视应用" };

const data = {
    "listing":
        [
            parent,
            ...categories.map(el => Object.assign({}, { parent }, el)),
        ],
    "status": "OK"
};

module.exports = function () {
    this.all('/tvapi/v1/apps/categories', async ctx => {
        console.log(ctx.request.href);
        ctx.type = 'text/html;charset=UTF-8';
        // ctx.body = '{"listing":[{"enName":"App","id":801,"name":"电视应用"},{"enName":"Games","id":805,"name":"电视游戏"},{"enName":"Education","id":809,"name":"教育学习","parent":{"enName":"App","id":801,"name":"电视应用"}},{"enName":"Daily life","id":812,"name":"生活日常","parent":{"enName":"App","id":801,"name":"电视应用"}},{"enName":"System tools","id":815,"name":"系统工具","parent":{"enName":"App","id":801,"name":"电视应用"}},{"enName":"Entertainment","id":824,"name":"影音娱乐","parent":{"enName":"App","id":801,"name":"电视应用"}},{"enName":"Casual puzzle","id":1025,"name":"休闲益智","parent":{"enName":"Games","id":805,"name":"电视游戏"}},{"enName":"Action fighting","id":1026,"name":"动作格斗","parent":{"enName":"Games","id":805,"name":"电视游戏"}},{"enName":"Sports","id":1028,"name":"体育竞技","parent":{"enName":"Games","id":805,"name":"电视游戏"}},{"enName":"Chess & Board","id":1029,"name":"棋牌桌游","parent":{"enName":"Games","id":805,"name":"电视游戏"}}],"status":"OK"}';
        ctx.body = JSON.stringify(data);
    });
}